package net.cooltain.warhammer.running.window.button;

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.event.MouseEvent;

import javax.swing.BorderFactory;

import net.cooltain.warhammer.framework.constant.ConstantPhases;
import net.cooltain.warhammer.running.entity.MotionPlayerZone;

public class Phases4Battle3ChooseDefendBtn extends PhasesBtn {

	private static final long serialVersionUID = 3940922163475535548L;
	
	public Phases4Battle3ChooseDefendBtn(MotionPlayerZone player) {
		super(player , "3."+ConstantPhases.BATTLE3_CHOOSE_DEFEND_CN , ConstantPhases.BATTLE3_CHOOSE_DEFEND);
		this.setFont(new Font("宋体", Font.PLAIN ,11 ));
		this.addMouseListener(this);
	}
	
	@Override
	public void paintComponent(Graphics g) {
		super.paintComponent(g);
		if(player.isMyTurn){
			if(player.currentPhases==ConstantPhases.BATTLEFIELD_PHASES){
				this.setEnabled(true);
				int currentPhases = player.currentPhasesBattle;
				if(currentPhases>this.phasesId){
					this.setEnabled(false);
					this.setBorder(BorderFactory.createLineBorder(Color.gray));
				}else if(currentPhases==this.phasesId){
					this.setEnabled(false);
					this.setBorder(BorderFactory.createLineBorder(Color.BLUE,3));
				}else{
					this.setEnabled(true);
					this.setBorder(BorderFactory.createLineBorder(Color.GRAY));
				}
			}else{
				this.setEnabled(false);
			}
			
		} else {
			if(player.operatePlayer.currentPhases==ConstantPhases.BATTLEFIELD_PHASES){
				this.setEnabled(true);
				int currentPhases = player.operatePlayer.currentPhasesBattle;
				if(currentPhases>this.phasesId){
					this.setEnabled(false);
					this.setBorder(BorderFactory.createLineBorder(Color.gray));
				}else if(currentPhases==this.phasesId){
					this.setEnabled(false);
					this.setBorder(BorderFactory.createLineBorder(Color.RED,3));
				}else{
					this.setEnabled(false);
					this.setBorder(BorderFactory.createLineBorder(Color.gray));
				}
			}else{
				this.setEnabled(false);
			}
			
		}
	}

	public void mouseClicked(MouseEvent e) {
		if(this.isEnabled()){
//		player.toPhases4BattleFieldPhases(); // TODO 
			this.setEnabled(false);
			player.mainFrame.reloadPhases();
			
		}
	}

}
